package com.shycloud.mido.common.util.rtc;

/**
 * @author Xiaoxing Yu
 * @date 2020/10/26 11:48 上午
 **/
public class RTCUtil {

	public static final String appId = "35d1cc59426a42659f9d5f2e17bd9ac3";

	public static final String appCertificate = "9e81197e665f4f09a5b37a972f40e27c";

	public static final Integer uid = 0;

	public static final String userAccount = "0";

	public static final Integer expirationTimeInSeconds = 86400;

	public static String genRTCToken(String channelName) {
		String tokenStr = null;

		//TODO 生成RTC Token
		RtcTokenBuilder token = new RtcTokenBuilder();
		int timestamp = (int)(System.currentTimeMillis() / 1000 + expirationTimeInSeconds);
//		tokenStr = token.buildTokenWithUserAccount(appId, appCertificate,
//				channelName, userAccount, RtcTokenBuilder.Role.Role_Publisher, timestamp);

		tokenStr = token.buildTokenWithUid(appId, appCertificate,
				channelName, uid, RtcTokenBuilder.Role.Role_Publisher, timestamp);

		return tokenStr;
	}

//	public static void main(String[] args) throws Exception {
//		System.out.println(genRTCToken(
//				System.nanoTime() + "_0000328031eeca3678ee4e656eb66068",
//				"0000328031eeca3678ee4e656eb66068"));
//
////		System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2020-10-26 00:00:00").getTime());
////		System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2020-10-26 23:59:59").getTime());
//	}

}
